<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

// 前台模块
Route::group(['namespace' => 'Home'], function(){
    // 首页
    Route::get('/', 'IndexController@index');
    // 栏目页
    Route::get('type/{id}', 'IndexController@type');
    // 文章页
    Route::get('article/{id}', 'IndexController@article');
    // 搜索页
    Route::get('search', 'IndexController@search');
    // 标签搜索页
    Route::get('tag/{id}', 'IndexController@tag');
    // 标签页
    Route::get('tags', 'IndexController@tags');
    // 专栏列表页
    Route::get('cases', 'IndexController@cases');
    // 专栏页
    Route::get('getcase/{id}', 'IndexController@getcase');
    // 时间轴
    Route::get('time', 'IndexController@time');
    // 留言板
    Route::post('comment', 'IndexController@comment');
    // 用户点赞ajax请求
    Route::get('praise/{id}', 'IndexController@praise');
});

// 用户登录、注册
Route::group(['namespace'=>'Admin','prefix'=>'admin'], function(){
    Route::group(['prefix'=>'login'], function(){
        Route::get('index', 'LoginController@index');
        Route::post('in', 'LoginController@in');
        Route::get('out', 'LoginController@out');
    });

});

// 后台模块
Route::group(['namespace'=>'Admin','prefix'=>'admin','middleware'=>'login'], function(){
    // 后台框架
    Route::get('index', 'IndexController@index');
    // 后台首页
    Route::get('main', 'IndexController@main');

    // 工具类控制器
    Route::group(['prefix' => 'tool'], function(){
        // 文件上传
        Route::match(['get', 'post'],'upload/{name?}/{dir?}/{isdate?}', 'ToolController@upload');
    });

    // 用户管理
    Route::group(['prefix' => 'user'], function(){
        // 用户列表
        Route::get('index', 'UserController@index');
        // 用户添加
        Route::get('create', 'UserController@create');
        Route::post('store', 'UserController@store');
        // 用户修改
        Route::get('edit/{id}', 'UserController@edit');
        Route::post('update/{id}', 'UserController@update');
        // 用户删除
        Route::get('destroy/{id}', 'UserController@destroy');
        // 批量删除
        Route::post('dels', 'UserController@dels');
        // 文件上传
        Route::post('upload', 'UserController@upload');
    });
    // 栏目管理
    Route::group(['prefix' => 'type'], function(){
        // 栏目列表
        Route::get('index', 'TypeController@index');
        // 栏目添加
        Route::get('create', 'TypeController@create');
        Route::post('store', 'TypeController@store');
        // 栏目修改
        Route::get('edit/{id}', 'TypeController@edit');
        Route::post('update/{id}', 'TypeController@update');
        // 栏目删除
        Route::get('destroy/{id}', 'TypeController@destroy');
        // 批量删除
        Route::post('dels', 'TypeController@dels');
        // 文件上传
        Route::post('upload', 'TypeController@upload');
    });
    // 标签管理
    Route::group(['prefix' => 'tag'], function(){
        // 标签列表
        Route::get('index', 'TagController@index');
        // 标签添加
        Route::get('create', 'TagController@create');
        Route::post('store', 'TagController@store');
        // 标签修改
        Route::get('edit/{id}', 'TagController@edit');
        Route::post('update/{id}', 'TagController@update');
        // 标签删除
        Route::get('destroy/{id}', 'TagController@destroy');
        // 批量删除
        Route::post('dels', 'TagController@dels');
    });
    // 专题管理
    Route::group(['prefix' => 'case'], function(){
        // 列表
        Route::get('index', 'CaseController@index');
        // 添加
        Route::get('create', 'CaseController@create');
        Route::post('store', 'CaseController@store');
        // 修改
        Route::get('edit/{id}', 'CaseController@edit');
        Route::post('update/{id}', 'CaseController@update');
        // 删除
        Route::get('destroy/{id}', 'CaseController@destroy');
        // 批量删除
        Route::post('dels', 'CaseController@dels');
    });
    // 文章管理
    Route::group(['prefix' => 'article'], function(){
        // 文章添加
        Route::get('create/{id?}', 'ArticleController@create');
        // Route::get('add/{id?}', 'ArticleController@add');
        Route::post('store', 'ArticleController@store');
        // 文章列表
        Route::get('index/{type_id?}', 'ArticleController@index');
        // 文章修改
        Route::get('edit/{id}', 'ArticleController@edit');
        Route::post('update/{id}', 'ArticleController@update');
        // 文章删除
        Route::get('destroy/{id}', 'ArticleController@destroy');
        // 批量删除
        Route::post('dels', 'ArticleController@dels');
    });
    // 评论管理
    Route::group(['prefix' => 'comment'], function(){
        // 评论列表
        Route::get('index/{type_id?}', 'CommentsController@index');
        // 评论修改
        Route::get('edit/{id}', 'CommentsController@edit');
        Route::post('update/{id}', 'CommentsController@update');
        // 评论删除
        Route::get('destroy/{id}', 'CommentsController@destroy');
        // 批量删除
        Route::post('dels', 'CommentsController@dels');
        // 批量审核
        Route::post('shenhe', 'CommentsController@shenhe');
    });
    // 配置分组管理
    Route::group(['prefix' => 'config_group'], function(){
        // 列表
        Route::get('index', 'ConfigGroupsController@index');
        // 添加
        Route::get('create', 'ConfigGroupsController@create');
        Route::post('store', 'ConfigGroupsController@store');
        // 修改
        Route::get('edit/{id}', 'ConfigGroupsController@edit');
        Route::post('update/{id}', 'ConfigGroupsController@update');
        // 删除
        Route::get('destroy/{id}', 'ConfigGroupsController@destroy');
        // 批量删除
        Route::post('dels', 'ConfigGroupsController@dels');
    });
    // 配置管理
    Route::group(['prefix' => 'configs'], function(){
        // 列表
        Route::get('index', 'ConfigsController@index');
        // 添加
        Route::get('create', 'ConfigsController@create');
        Route::post('store', 'ConfigsController@store');
        // 修改
        Route::get('edit/{id}', 'ConfigsController@edit');
        Route::post('update/{id}', 'ConfigsController@update');
        Route::post('update_all', 'ConfigsController@update_all');
        // 删除
        Route::get('destroy/{id}', 'ConfigsController@destroy');
        // 批量删除
        Route::post('dels', 'ConfigsController@dels');
    });
});
